import jwt
import datetime
from django.conf import settings
def create_token(payload, timeout):
# jwt功能
    salt = settings.SECRET_KEY
    # Header
    headers = {
        "typ":'jwt',
        'alg':'HS256'
    }
    #payload
    payload["exp"] = datetime.datetime.utcnow() + datetime.timedelta(minutes=timeout) #超时时间
    token = jwt.encode(payload = payload,key=salt,algorithm='HS256',headers=headers)
    return token